package com.qiantu.api.http.model;

import com.hjq.http.config.IRequestServer;
import com.hjq.http.model.BodyType;
import com.qiantu.api.BuildConfig;
import com.qiantu.api.http.HttpBaseData;

/**
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2020/10/02
 *    desc   : 服务器配置
 */
public class RequestServer implements IRequestServer {

    @Override
    public String getHost() {
        if(HttpBaseData.getInstance().isLanMode){
            String ip =  HttpBaseData.getInstance().getLanIP();
            return "http://" + ip + ":63581/api/";
        }else if(HttpBaseData.getInstance().isLocalService()){
            if(HttpBaseData.getInstance().getLocalServiceUrl().contains("http://")){
                return HttpBaseData.getInstance().getLocalServiceUrl() + "/api/";
            }else{
                return "http://" + HttpBaseData.getInstance().getLocalServiceUrl() + "/api/";
            }
        }else{
            return BuildConfig.HOST_URL + "api/";
        }
    }

    @Override
    public BodyType getBodyType() {
        // 以表单的形式提交参数
        return BodyType.JSON;
    }
}